<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >

    <ui:composition template="layout.xhtml">

        <ui:define name="corpo">
            <h:form acceptcharset="utf-8" id="verImovel" enctype="multipart/form-data"> 
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexImovel.xhtml')}" value="Imóvel" update="@form" immediate="true"/> >
                    <p:commandLink  value="Averbação" update="@form" immediate="true"/>
                </div>
                <p:panel header="Averbar Imóvel - #{managerAverbacao.imovel.registro}">                        
                 <p:messages id="msg"/>

                    <h:panelGrid  columns="4" border="0" styleClass="textAlignRightBold">  

                        <h:outputLabel value="Origem do Imóvel:" />
                        <h:outputText value="#{managerAverbacao.imovel.operacao.tipo}" />

                        <h:outputLabel value=" " />
                        <h:outputLabel value=" " />

                        <h:outputLabel value="Registro: "/> 

                        <h:outputText value="#{managerAverbacao.imovel.registro}" />

                        <h:outputLabel value="Data:"/>                       
                        <h:outputText value="#{managerAverbacao.imovel.dataCadastro}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </h:panelGrid>


                    <fieldset class="ui-fieldset">
                        <legend><h:outputLabel value="Titulo"/></legend>
                        <h:panelGrid columns="2" id="panelGridTitulo" styleClass="textAlignRightBold">
                            <h:outputLabel value="Titulo: "/> 
                            <h:outputText value="#{managerAverbacao.transferencia.titulo.nome}"/>

                            <h:outputLabel value="Forma titulo: " />
                            <h:outputText value="#{managerAverbacao.transferencia.formaTitulo}" />
                        </h:panelGrid>
                    </fieldset>

                    <br/>
                    <p:tab id="tabRegistroAnterior" rendered="#{empty managerAverbacao.imovel.imovelAnterior ? false : true}" >
                        <fieldset class="ui-fieldset" >
                            <legend><h:outputLabel value="Registro Anterior"/></legend>
                            <h:panelGrid columns="2" id="panelGridRegAnterior" styleClass="textAlignRightBold">

                                <h:outputLabel value="Número do(s) Registro(s):"/>
                                <ui:repeat value="#{managerAverbacao.imovel.imovelAnterior}" var="info">
                                    <p:commandLink value="#{info.registro}" actionListener="#{managerBuscarImovel.verAnterior(info)}"  />
                                    <h:outputText value=", "/>
                                </ui:repeat>
                            </h:panelGrid>
                        </fieldset>
                        <br/>
                    </p:tab>

                    <fieldset class="ui-fieldset">
                        <legend><h:outputLabel value="Objeto"/></legend>

                        <h:outputLabel value="Objeto: "/> 
                        <h:outputText value="Um(a) #{managerAverbacao.imovel.objeto.tipo} localizada(o) na #{managerAverbacao.imovel.objeto.tipo_logradouro} 
                                      #{managerAverbacao.imovel.objeto.logradouro}, #{managerAverbacao.imovel.objeto.numero}, bairro #{managerAverbacao.imovel.objeto.bairro}; com as
                                      seguintes confrontações: frente, #{managerAverbacao.imovel.objeto.frente}, lado direito, #{managerAverbacao.imovel.objeto.ladoDireito}, lado esquerdo,
                                      #{managerAverbacao.imovel.objeto.ladoEsquerdo}
                                      " escape="true" /> 

                    </fieldset>
                    <br/>
                    <fieldset class="ui-fieldset">
                        <legend><h:outputLabel value="Averbação"/></legend>
                        <h:panelGrid columns="2">
                            <h:outputLabel value="Descrição: "/> 
                            <p:inputTextarea cols="104" value="#{managerAverbacao.averbacao.descricao}" />
                        </h:panelGrid>
                    </fieldset>
                    
                    <div class="buttonAction">
                        <p:commandButton id="upa" icon="ui-icon-disk" value="Averbar" actionListener="#{managerAverbacao.salvar()}" update="@form" process="@form"/>
                        <p:commandButton id="limpar" icon="ui-icon-close" value="limpar" type="reset" />  
                    
                        <p:ajaxStatus style="width:16px;height:16px;" id="ajaxStatusPanel">  
                            <f:facet name="start">  
                                <h:graphicImage value="/media/img/loading.gif" />  
                            </f:facet>  

                            <f:facet name="complete">  
                                <h:outputText value="" />  
                            </f:facet>  
                        </p:ajaxStatus>

                    </div>
                </p:panel>  

                <p:dialog widgetVar="verMap" header="Imóvel Geocodificado" style="width:100%" modal="true">
                    <p:gmap center="-2.92867970, -41.75083009999999" zoom="13" type="HYBRID"
                            style="width:600px;height:400px"  
                            model="#{managerGmap.simpleModel}">
                        <p:ajax event="markerDrag" listener="#{managerGmap.onMarkerDrag}" update="msg"/>
                        <p:ajax event="overlaySelect" listener="#{managerGmap.onMarkerSelect}" />

                        <p:gmapInfoWindow>  
                            <h:outputLabel value="Registro: " /> 
                            <h:outputText value="#{managerAverbacao.imovel.registro}" />
                        </p:gmapInfoWindow>  
                    </p:gmap>  
                </p:dialog>


            </h:form>
        </ui:define>
    </ui:composition>
</html>

